package com.gjy.design.prototype;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-11-11 09:35:39
 */
public class Address implements Serializable {
    private static final long serialVersionUID = -8494336529985333117L;

    private String street;
    private int houseNumber;

    public Address(String street, int houseNumber) {
        this.street = street;
        this.houseNumber = houseNumber;
    }

    // 为演示深拷贝提供拷贝构造器
    public Address(Address other) {
        this.street = other.street;
        this.houseNumber = other.houseNumber;
    }

    // getters / setters
    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public int getHouseNumber() {
        return houseNumber;
    }

    public void setHouseNumber(int houseNumber) {
        this.houseNumber = houseNumber;
    }

    @Override
    public String toString() {
        return "Address{street='" + street + "', houseNumber=" + houseNumber + '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Address)) return false;
        Address address = (Address) o;
        return houseNumber == address.houseNumber &&
                Objects.equals(street, address.street);
    }

    @Override
    public int hashCode() {
        return Objects.hash(street, houseNumber);
    }
}
